#include <stdbool.h>
int TreeLevelSize(struct TreeNode* root, int* flag)
{
    if (root == NULL)
        return 0;
    if (root->left == root->right && root->left == NULL)
    {
        return 1;
    }
    int n = TreeLevelSize(root->left, flag);
    int m = TreeLevelSize(root->right, flag);
    int sum;
    if (n > m)
        sum = n - m;
    else
    {
        sum = m - n;
        n = m;
    }
    if (sum >= 2)
    {
        *flag = 0;
    }
    return n + 1;
}



bool IsBalanced_Solution(struct TreeNode* pRoot) {
    // write code here
    int flag = 1;
    TreeLevelSize(pRoot, &flag);
    if (flag == 0)
        return false;
    return true;

}